package 力扣._100040_让所有学生保持开心的分组方法数;

import java.util.Comparator;
import java.util.List;

public class Solution {
    public int countWays(List<Integer> nums) {
        //先排序
        nums.sort((Comparator.comparingInt(o -> o)));
        int total = 0;
        if (nums.get(0) > 0)
            total++;
        for (int i = 0; i < nums.size() - 1; i++) {
            int len = i + 1;
            if (len > nums.get(i) && len < nums.get(i + 1))
                total++;
        }
        if (nums.get(nums.size() - 1) < nums.size())
            total++;
        return total;
    }
}
